<template>
    <div class="order-report">
        <div class="report-table-top-title">商家列表</div>
        <div class="report-table-form1">
            <el-form ref="form" size="small" inline label-width="80px">
                <el-form-item label="商家编号:" prop="originNo">
                    <el-input
                        v-model="searchNo"
                        placeholder
                        class="items"
                        size="small"
                        suffix-icon="el-icon-search"
                    ></el-input>
                </el-form-item>
                <el-form-item label="商家名称:" prop="originNo">
                    <el-input
                        v-model="searchName"
                        placeholder
                        size="small"
                        class="items"
                        suffix-icon="el-icon-search"
                    ></el-input>
                </el-form-item>
                <el-form-item
                    label="总店编号:"
                    prop="mainCompanyCode"
                    v-if="managementType === 3"
                >
                    <el-input
                        v-model="mainCompanyCode"
                        placeholder
                        size="small"
                        class="items"
                        suffix-icon="el-icon-search"
                    ></el-input>
                </el-form-item>
                <el-form-item
                    label="总店名称:"
                    prop="mainCompanyName"
                    v-if="managementType === 3"
                >
                    <el-input
                        v-model="mainCompanyName"
                        placeholder
                        size="small"
                        class="items"
                        suffix-icon="el-icon-search"
                    ></el-input>
                </el-form-item>

                <el-form-item label="代理商:" prop="originNo">
                    <el-select
                        v-model="value1"
                        class="items"
                        filterable
                        placeholder="请选择"
                        size="small"
                    >
                        <el-option label="全部" value=""></el-option>
                        <el-option
                            v-for="item in options1"
                            :key="item.id"
                            :label="item.agentName"
                            :value="item.id"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="注册时间:" prop="originNo">
                    <el-date-picker
                        v-model="beginTime"
                        type="date"
                        style="width: 180px"
                        size="small"
                        value-format="yyyy-MM-dd"
                        format="yyyy-MM-dd"
                        placeholder="选择日期时间"
                    >
                    </el-date-picker>

                    <span>至:</span>
                    <el-date-picker
                        v-model="endTime"
                        style="width: 180px"
                        type="date"
                        size="small"
                        value-format="yyyy-MM-dd"
                        format="yyyy-MM-dd"
                        placeholder="选择日期时间"
                    >
                    </el-date-picker>
                    <el-button type="primary" size="small" @click="search"
                        >搜索</el-button
                    >
                    <el-button type="primary" size="small" @click="exportRport"
                        >导出Excel</el-button
                    >
                    <el-dropdown trigger="click">
                            <el-button type="primary" size="small">
                                    多数据操作<i
                                        class="
                                            el-icon-arrow-down
                                            el-icon--right
                                        "
                                    ></i>
                                </el-button>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item
                                    @click.native="showValue=true"
                                    >同步商家数据</el-dropdown-item
                                >
                                <el-dropdown-item
                                    @click.native="isShowBatchAll=true"
                                    >批量指定应用包</el-dropdown-item
                                >
                            </el-dropdown-menu>
                        </el-dropdown>
                </el-form-item>
            </el-form>
        </div>
        <div class="page-padding-gray-small"></div>
        <div class="report-table-wrapper">
            <el-table
                :header-cell-style="headerCellStyle"
                size="small"
                :data="showList"
                border
            >
                <el-table-column
                    prop="companyCode"
                    label="商家编号"
                    min-width="100"
                ></el-table-column>
                <el-table-column
                    prop="companyName"
                    label="商家名称"
                    show-overflow-tooltip
                    min-width="100"
                ></el-table-column>
                <el-table-column
                    prop="mainCompanyCode"
                    v-if="managementType === 3"
                    label="总店编号"
                    min-width="100"
                ></el-table-column>
                <el-table-column
                    prop="mainCompanyName"
                    label="总店名称"
                    v-if="managementType === 3"
                    show-overflow-tooltip
                    min-width="100"
                ></el-table-column>
                <el-table-column
                    prop="createtime"
                    label="注册时间"
                    min-width="100"
                >
                    <template slot-scope="props">
                        <div>{{ $FS(props.row.createtime) }}</div>
                    </template>
                </el-table-column>
                <el-table-column
                    v-if="managementType !== 3 && managementType !== 4"
                    prop="temporaryExpiredTime"
                    label="临时限制"
                    min-width="100"
                >
                    <template slot-scope="props">
                        <div>{{ $FS(props.row.temporaryExpiredTime) }}</div>
                    </template>
                </el-table-column>
                <el-table-column
                    v-if="managementType !== 3"
                    prop="expiredTime"
                    label="软件过期时间"
                    min-width="100"
                >
                    <template slot-scope="props">
                        <div v-show="!$IN7DAY(props.row.expiredTime)">
                            {{ $FS(props.row.expiredTime) }}
                        </div>
                        <div
                            v-show="$IN7DAY(props.row.expiredTime)"
                            style="color: red"
                        >
                            {{ $FS(props.row.expiredTime) }}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    v-if="managementType !== 3 && managementType !== 4"
                    prop="roomPoint"
                    label="卡台数"
                    min-width="70"
                ></el-table-column>
                <el-table-column
                    prop="netPayChannel"
                    label="支付通道"
                    min-width="70"
                >
                    <template slot-scope="scope">
                        <div v-if="scope.row.netPayChannel === 1">娱加</div>
                        <div v-if="scope.row.netPayChannel === 2">K米</div>
                        <div v-if="scope.row.netPayChannel === 3">
                            原生微信/支付宝
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="netPayRate"
                    label="支付费率(单位/千分)"
                    min-width="70"
                >
                    <template slot-scope="scope">
                        {{
                            scope.row.netPayChannel === 2 ||
                            scope.row.netPayChannel === 3
                                ? '-'
                                : scope.row.netPayRate
                        }}
                    </template>
                </el-table-column>
                <el-table-column
                    prop="agentName"
                    label="代理商"
                    min-width="100"
                ></el-table-column>
                <el-table-column
                    prop="addServiceCompanyList"
                    label="增值服务列表"
                    show-overflow-tooltip
                    min-width="100"
                >
                    <template slot-scope="props">
                        <span
                            v-for="(item, index) in props.row
                                .addServiceCompanyList"
                            :key="index"
                            >{{ item.addServiceName }},</span
                        >
                    </template>
                </el-table-column>
                <el-table-column label="操作" width="220" fixed="right">
                    <template slot-scope="scope">
                        <el-button
                            v-if="scope.row.status == 2 && false"
                            size="mini"
                            type="primary"
                            >已退货</el-button
                        >
                        <template v-else>
                            <el-button
                                size="mini"
                                type="primary"
                                @click="toModify(scope.$index, scope.row)"
                                >修改商家</el-button
                            >
                            <el-dropdown
                                trigger="click"
                            >
                                <el-button type="primary" size="mini">
                                    更多操作<i
                                        class="
                                            el-icon-arrow-down
                                            el-icon--right
                                        "
                                    ></i>
                                </el-button>
                                <el-dropdown-menu slot="dropdown">
                                    <el-dropdown-item
                                        @click.native="resetPassword(scope.row)"
                                        v-if="
                                            managementType !== 3 &&
                                            roleId === 1 &&
                                            (manageRoleType === 0 ||
                                                manageRoleType === 4 ||
                                                manageRoleType === 5)
                                        "
                                        >重置密码</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        @click.native="
                                            toNetPayChannel(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >网络支付配置</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        @click.native="
                                            toHistory(scope.$index, scope.row)
                                        "
                                        >变更记录</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        @click.native="
                                            toUpdateHistory(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >升级记录</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        @click.native="
                                            refreData(scope.$index, scope.row)
                                        "
                                        v-show="
                                            managementType !== 3 &&
                                            (manageRoleType === 0 ||
                                                manageRoleType === 5)
                                        "
                                        >终端数据提取</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-show="false"
                                        @click.native="
                                            toServiceList(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >增值服务列表</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-show="manageRoleType === 0 && false"
                                        @click.native="
                                            changeService(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >变更增值服务</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-show="
                                            managementType !== 3 &&
                                            (manageRoleType === 0 ||
                                                manageRoleType === 5)
                                        "
                                        @click.native="
                                            downData(scope.$index, scope.row)
                                        "
                                        >终端数据下载</el-dropdown-item
                                    >

                                    <el-dropdown-item
                                        v-show="
                                            managementType !== 3 &&
                                            manageRoleType === 0 &&
                                            managementType !== 4
                                        "
                                        @click.native="openCheck(scope.row)"
                                        >特殊授权</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        @click.native="
                                            toWareInputReview(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >进件查看</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-if="
                                            managementType == 4 ||
                                            managementType === 2
                                        "
                                        @click.native="
                                            projectorEdition(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >指定皮肤包版本</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-if="
                                            managementType !== 3 &&
                                            roleId === 1 &&
                                            (manageRoleType === 0 ||
                                                manageRoleType === 5)
                                        "
                                        @click.native="
                                            getVersionList(
                                                scope.$index,
                                                scope.row
                                            )
                                        "
                                        >指定apk版本</el-dropdown-item
                                    >

                                    <el-dropdown-item
                                        @click.native="
                                            toBatch(scope.row)
                                        "
                                        >指定应用包</el-dropdown-item
                                    >

                                    <el-dropdown-item
                                        @click.native="
                                            toEdition(scope.$index, scope.row)
                                        "
                                        >查看版本</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-show="
                                            roleId === 1 &&
                                            (manageRoleType === 0 ||
                                                manageRoleType === 3)
                                        "
                                        @click.native="
                                            temporaryAuthorization(scope.row)
                                        "
                                        >临时授权</el-dropdown-item
                                    >
                                    <el-dropdown-item
                                        v-show="
                                            roleId === 1 &&
                                            (manageRoleType === 0 ||
                                                manageRoleType === 3) &&
                                            managementType !== 3
                                        "
                                        @click.native="returnGood(scope.row)"
                                        >退货</el-dropdown-item
                                    >
                                </el-dropdown-menu>
                            </el-dropdown>
                        </template>
                    </template>
                </el-table-column>
                <el-table-column type="expand" v-if="managementType !== 3">
                    <template slot-scope="props">
                        <div style="line-height: 18px; font-size: 16px">
                            <div>联系人：{{ props.row.contact }}</div>
                            <div>联系方式：{{ props.row.telPhone }}</div>
                            <div v-show="props.row.managementType === 3">
                                总店编号：{{ props.row.mainCompanyCode }}
                            </div>
                            <div>
                                经营类型：{{
                                    props.row.managementTypeName
                                }}（有效期至{{ $F(props.row.expiredTime) }}）
                            </div>
                            <div>
                                商家地址：{{ props.row.provincialLevelName }}省
                                {{ props.row.cityLevelName }}市
                                {{ props.row.address }}
                            </div>
                            <div>备注：{{ props.row.remark }}</div>
                            <div>
                                日志更新时间：{{ $F(props.row.uploadTime) }}
                            </div>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
        </div>

        <div class="report-table-block">
            <div class="report-table-block-in">
                <el-pagination
                    background
                    :current-page.sync="position"
                    @current-change="handleCurrentChange"
                    :page-size="10"
                    layout="prev, pager, next, total"
                    :total="totalNum"
                ></el-pagination>
            </div>
        </div>
        <el-dialog
            title="变更增值服务"
            :visible.sync="dialogServiceVisible"
            width="700px"
        >
            <el-form label-position="right">
                <el-form-item label="商家编号">
                    <div>{{ this.companyCodeInfo }}</div>
                </el-form-item>
                <el-form-item label="商家名称">
                    <div>{{ this.companyNameInfo }}</div>
                </el-form-item>
                <el-form-item label="卡台">
                    <el-checkbox v-model="checkB" @change="serviceCheckB"
                        >卡台B段(16-25)</el-checkbox
                    >
                    <el-checkbox v-model="checkC" @change="serviceCheckC"
                        >卡台C段(26-35)</el-checkbox
                    >
                </el-form-item>
                <!-- <el-form-item label="卡台C段">
                    <el-button type="primary" @click="okDialog" size="small">授 权</el-button>
                    <el-button type="primary" @click="okDialog" size="small">取消授权</el-button>
                </el-form-item> -->
                <el-form-item label="数据可查">
                    <el-radio v-model="serviceSelect" :label="''"
                        >默认赠送</el-radio
                    >
                    <el-radio v-model="serviceSelect" :label="'LYJB003'"
                        >100天</el-radio
                    >
                    <el-radio v-model="serviceSelect" :label="'LYJB004'"
                        >200天</el-radio
                    >
                    <el-radio v-model="serviceSelect" :label="'LYJB005'"
                        >400天</el-radio
                    >
                    <el-radio v-model="serviceSelect" :label="'LYJB006'"
                        >600天</el-radio
                    >
                    <el-radio v-model="serviceSelect" :label="'LYJB007'"
                        >800天</el-radio
                    >
                </el-form-item>
                <el-form-item
                    label="数据可查过期时间"
                    v-show="serviceSelect !== ''"
                >
                    <!-- <el-date-picker
                    size="small"
                    v-model="timeStart"
                    type="date"
                    width="135px"
                    value-format="yyyy-MM-dd"
                    placeholder="开始日期"
                ></el-date-picker>至 -->
                    <el-date-picker
                        size="small"
                        v-model="timeEnd"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="结束日期"
                    ></el-date-picker>
                </el-form-item>
                <el-form-item label="霸屏" v-show="showBapingServe">
                    <el-checkbox
                        v-model="hasBaping"
                        @change="serviceBapingCheck"
                    ></el-checkbox>
                </el-form-item>
                <el-form-item label="霸屏过期时间" v-show="hasBaping">
                    <el-date-picker
                        size="small"
                        v-model="bapingTimeEnd"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="结束日期"
                    ></el-date-picker>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancelDialog" size="small">取 消</el-button>
                <el-button type="primary" @click="okDialog" size="small"
                    >确 定</el-button
                >
            </div>
        </el-dialog>
        <el-dialog
            title="特殊授权"
            :visible.sync="dialogVisibleCheck"
            width="450px"
        >
            <el-form size="small">
                <el-form-item label="特殊授权：" label-width="100">
                    <el-checkbox v-model="check1">支持大网协议</el-checkbox>
                    <!-- <el-checkbox v-model="check2">支持{{specPointStart}}~{{authMaxPoint}}点数注册</el-checkbox> -->
                    <el-checkbox v-model="check2"
                        >支持特殊授权卡台数</el-checkbox
                    >
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" size="mini" @click="saveCheck"
                    >确定</el-button
                >
            </span>
        </el-dialog>
        <!-- 
        <el-dialog title="终端数据拉取" :visible.sync="dialogVisible1" width="600px">
             <el-checkbox-group v-model="checkList">
                <el-checkbox label="1"> 日志提取</el-checkbox>
                <div>
                    <el-button style="background:white;border:none;color:#303133;margin:20px 0;font-size:17px" type="primary" size="mini" >选择更新日期范围</el-button>
                <el-date-picker
                v-model="date"
                type="daterange"
                align="right"
                unlink-panels
                style="margin-left:10px"
                value-format="yyyy-MM-dd 00:00:00"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :picker-options="pickerOptions2"
            ></el-date-picker>
                <div></div>
                </div>
                <el-checkbox label="2">数据提取</el-checkbox>
            </el-checkbox-group>
     
            <span slot="footer" class="dialog-footer">
                <el-button
                    type="primary"
                    size="small"
                    @click="realRefreshAll"
                    :disabled="buttonDisabled"
                >拉取</el-button>
            </span>
        </el-dialog>-->

        <el-dialog
            title="终端数据提取"
            :visible.sync="dialogVisible1"
            :close="clearData"
            :before-close="clearData"
            width="600px"
        >
            <div style="margin: -10px 0 10px 10px">
                <el-form
                    ref="form"
                    size="small"
                    @submit.native.prevent
                    :model="form"
                    :rules="rules"
                    label-width="140px"
                >
                    <el-form-item label="提取类型" prop="upType">
                        <el-radio-group v-model="form.upType">
                            <el-radio :label="1">日志提取</el-radio>
                            <el-radio :label="2">数据提取</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item
                        label="设备类型:"
                        prop="terminalType"
                        v-if="managementType === 4 && form.upType === 1"
                    >
                        <el-select
                            v-model="form.terminalType"
                            class="item"
                            filterable
                            @change="getSNList"
                            placeholder="请选择"
                        >
                            <el-option
                                v-for="(item, index) in terminalTypeList"
                                :key="index"
                                :label="item.terminalTypeName"
                                :value="item.terminalType"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item
                        label="SN码:"
                        prop="snCode"
                        v-if="managementType === 4 && form.upType === 1"
                    >
                        <el-select
                            v-model="form.snCode"
                            class="item"
                            filterable
                            placeholder="请选择"
                        >
                            <el-option
                                v-for="(item, index) in snList"
                                :key="index"
                                :label="item"
                                :value="item"
                            ></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item
                        label="日志提取时间:"
                        prop="serviceDate"
                        v-if="form.upType === 1"
                    >
                        <el-date-picker
                            v-model="form.serviceDate"
                            type="daterange"
                            align="right"
                            unlink-panels
                            value-format="yyyy-MM-dd"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :picker-options="pickerOptions2"
                        ></el-date-picker>
                    </el-form-item>
                </el-form>
                <div style="text-align: center">
                    <el-button
                        size="mini"
                        type="primary"
                        v-if="form.upType === 1"
                        :loading="upLoading"
                        @click="realRefresh"
                        >提取</el-button
                    >
                    <el-button
                        size="mini"
                        v-if="form.upType === 2"
                        type="primary"
                        :loading="upLoading"
                        style="margin-left: 20px"
                        @click="realRefreshTwo(true)"
                        >提取</el-button
                    >
                </div>
            </div>
            <!-- <div style="margin: 10px 0 20px 20px">
                <el-button
                    size="mini"
                    type="primary"
                    v-if="isSuccess"
                    @click="realRefresh"
                    >日志提取</el-button
                >
                <el-button
                    size="mini"
                    type="primary"
                    :disabled="isSuccess"
                    v-if="!isSuccess"
                    >日志提取中</el-button
                >
                <el-button
                    size="mini"
                    type="primary"
                    style="margin-left: 20px"
                    @click="realRefreshTwo(true)"
                    v-if="!dbUploading"
                    >数据提取</el-button
                >
                <el-dropdown
                    trigger="click"
                    style="margin-left: 20px"
                    v-if="dbUploading"
                    @command="handleCommand"
                >
                    <el-button plain size="mini" type="primary"
                        >数据提取中</el-button
                    >
                    <el-dropdown-menu slot="dropdown">
                        <el-dropdown-item
                            type="primary"
                            @click="dbUploadingEvent"
                            >强制提取数据</el-dropdown-item
                        >
                    </el-dropdown-menu>
                </el-dropdown>
            </div> -->
            <div style="margin: 10px 0 10px 20px"></div>
        </el-dialog>
        <el-dialog
            title="终端数据下载"
            :visible.sync="dialogVisible2"
            :close="clearData2"
            :before-close="clearData2"
            width="800px"
        >
            <el-form
                ref="downForm"
                size="small"
                @submit.native.prevent
                :model="downForm"
                :rules="downRules"
                label-width="140px"
            >
                <el-form-item label="类型" prop="downType">
                    <el-radio-group v-model="downForm.downType">
                        <el-radio :label="1">日志下载</el-radio>
                        <el-radio :label="4">基础数据下载</el-radio>
                        <el-radio :label="5">营业数据下载</el-radio>
                        <el-radio :label="6" v-if="managementType === 2"
                            >持久化数据下载</el-radio
                        >
                    </el-radio-group>
                </el-form-item>
                <el-form-item
                    label="设备类型:"
                    prop="terminalType"
                    v-if="managementType === 4 && downForm.downType === 1"
                >
                    <el-select
                        v-model="downForm.terminalType"
                        class="item"
                        filterable
                        @change="getSNList"
                        placeholder="请选择"
                    >
                        <el-option
                            v-for="(item, index) in terminalTypeList"
                            :key="index"
                            :label="item.terminalTypeName"
                            :value="item.terminalType"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item
                    label="SN码:"
                    prop="snCode"
                    v-if="managementType === 4 && downForm.downType === 1"
                >
                    <el-select
                        v-model="downForm.snCode"
                        class="item"
                        filterable
                        placeholder="请选择"
                    >
                        <el-option
                            v-for="(item, index) in snList"
                            :key="index"
                            :label="item"
                            :value="item"
                        ></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div style="text-align: center">
                <el-button
                    size="mini"
                    type="primary"
                    :loading="isLoading"
                    @click="downloadLog(downForm.downType)"
                    >下载</el-button
                >
            </div>
            <!-- <el-button size="mini" type="primary" @click="downloadLog(1)"
                >日志下载</el-button
            >

            <el-button size="mini" type="primary" @click="downloadLog(4)"
                >基础数据下载</el-button
            >

            <el-button size="mini" type="primary" @click="downloadLog(5)"
                >营业数据下载</el-button
            >

            <el-button
                size="mini"
                type="primary"
                v-if="managementType === 2"
                @click="downloadLog(6)"
                >持久化数据下载</el-button
            > -->
        </el-dialog>

        <!-- <el-dialog title="可升级终端版本" :visible.sync="showChangeVersion">
            <el-table :data="editVersionList">
                <el-table-column
                    property="versionCode"
                    label="版本号"
                    width="150"
                ></el-table-column>
                <el-table-column
                    property="versionName"
                    label="版本名称"
                    width="220"
                ></el-table-column>
                <el-table-column
                    property="mustupdata"
                    label="强制升级"
                    width="80"
                >
                    <template slot-scope="scope">
                        <div v-show="scope.row.mustupdata === 0">是</div>
                        <div v-show="scope.row.mustupdata === 1">否</div>
                    </template>
                </el-table-column>
                <el-table-column property="releaseDate" label="发布日期">
                    <template slot-scope="scope">{{
                        $F(scope.row.releaseDate)
                    }}</template>
                </el-table-column>
                <el-table-column label="操作" width="150">
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="primary"
                            @click="changeVersion(scope.$index, scope.row)"
                            >指定版本</el-button
                        >
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog> -->

        <el-dialog
            title="可选择皮肤包"
            width="1100px"
            :visible.sync="showTheme"
        >
            <el-table :data="editThemeListAfter">
                <el-table-column
                    prop="name"
                    label="皮肤包名称"
                ></el-table-column>
                <el-table-column prop="typeName" label="皮肤包类型">
                </el-table-column>
                <el-table-column prop="terminalTypeName" label="设备类型">
                </el-table-column>
                <el-table-column prop="mustUpdate" label="是否强制升级">
                    <template slot-scope="scope">
                        <div v-show="scope.row.mustUpdate === 0">不强制</div>
                        <div v-show="scope.row.mustUpdate === 1">强制</div>
                    </template>
                </el-table-column>
                <el-table-column prop="createTime" label="添加日期">
                    <template slot-scope="scope">{{
                        $F(scope.row.createTime)
                    }}</template>
                </el-table-column>
                <el-table-column prop="updateTime" label="更新日期">
                    <template slot-scope="scope">{{
                        $F(scope.row.updateTime)
                    }}</template>
                </el-table-column>
                <el-table-column label="操作" width="75">
                    <template slot-scope="scope">
                        <el-button
                            size="mini"
                            type="primary"
                            @click="changeTheme(scope.$index, scope.row)"
                            >推送</el-button
                        >
                        <!-- <el-button
                            size="mini"
                            type="primary"
                            @click="changeVersion(scope.$index, scope.row)"
                        >指定皮肤包</el-button> -->
                    </template>
                </el-table-column>
            </el-table>
        </el-dialog>
        <!-- 费率修改 -->
        <el-dialog title="费率修改" :visible.sync="showRate" width="450px">
            <div>
                <el-input
                    v-model="currentRate"
                    placeholder
                    size="small"
                ></el-input>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" size="mini" @click="saveRate"
                    >确定</el-button
                >
            </span>
        </el-dialog>

        <div class="page-padding"></div>
        <div
            class="page-all-loading"
            v-loading="isUploading"
            v-show="isUploading"
            element-loading-text="日志提取中，请稍后"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.7)"
        ></div>
        <div class="page-padding"></div>
        <div
            class="page-all-loading"
            v-loading="isdbUploading"
            v-show="isdbUploading"
            element-loading-text="数据提取中，请稍后"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.7)"
        ></div>

        <div
            class="page-all-loading"
            v-loading="isLoading"
            v-show="isLoading"
            element-loading-text="正在下载日志，请稍后"
            element-loading-spinner="el-icon-loading"
            element-loading-background="rgba(0, 0, 0, 0.7)"
        ></div>
        <projectorDialog
            :currRow="currRow"
            :value.sync="isShowProjector"
            @getPage="getPage"
        ></projectorDialog>
        <appointAPK
            :currRow="currRow"
            :value.sync="showChangeVersion"
            @getPage="getPage"
        ></appointAPK>
        <authorizationDialog
            :currRow="currRow"
            :value.sync="showTemporaryAuthorization"
            @getList="getPage"
        ></authorizationDialog>
        <synchronousShop
            :managementType="managementType"
            :value.sync="showValue"
            :type='1'
        ></synchronousShop>
        <batchMerchant
            :managementType="managementType"
            :value.sync="isShowBatchAll"
            @getList="getPage"
        ></batchMerchant>
        <addPlace
            :value.sync="isShowBatch"
            :currRow="currRow"
            @getList="getPage"
        ></addPlace>
    </div>
</template>

<script type="text/ecmascript-6">
import fileDownload from 'js-file-download'
import axios from 'axios'
import projectorDialog from './components/projectorDialog'
import appointAPK from './components/appointAPK'
import authorizationDialog from './components/authorizationDialog'
import synchronousShop from './components/synchronousShop'
import batchMerchant from './components/batchMerchant'
import addPlace from './components/addPlace'
export default {
    data: function () {
        return {
            pickerOptions2: {
                shortcuts: [
                    {
                        text: '最近一周',
                        onClick (picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
                            picker.$emit('pick', [start, end])
                        }
                    },
                    {
                        text: '最近两周',
                        onClick (picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 14)
                            picker.$emit('pick', [start, end])
                        }
                    },
                    {
                        text: '最近一个月',
                        onClick (picker) {
                            const end = new Date()
                            const start = new Date()
                            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
                            picker.$emit('pick', [start, end])
                        }
                    }
                ]
            },
            showValue: false,
            isShowBatchAll: false,
            isShowBatch: false,
            mainCompanyName: '',
            mainCompanyCode: '',
            downStatus: true,
            beginTime: '',
            endTime: '',
            date: '',
            showTemporaryAuthorization: false,
            checkList: [],
            checkListDownload: [],
            ossUploadDBUrl: '',
            showBapingServe: false,
            hasBaping: false,
            bapingTimeEnd: '',
            dialogVisible1: false,
            dialogVisible2: false,
            companyID: '',
            isShowProjector: false,
            upLoading: false,
            dbUploading: true,
            isSuccess: true,
            hasLog: false,
            showChangeVersion: false,
            dialogServiceVisible: false, // 变更增值服务弹窗
            editVersionCompanyId: '',
            editVersionList: [],
            terminalTypeList: [],
            nowPage: 0, // 当前所在页面

            options1: [
            ],
            value1: '',

            buttonDisabled: false,
            showList: [],
            testList: [
                {
                    reservedNo: '1234567',
                    roomName: '测试商家名称',
                    guestName: '2018-12-12 01:02:03',
                    agent: '福建视易',
                    businessMgrName: '111'
                },
                {
                    reservedNo: '1234567',
                    roomName: '测试商家名称',
                    guestName: '2018-12-12 01:02:03',
                    agent: '福建视易',
                    businessMgrName: '111'
                }
            ],
            snList: [],
            downForm: {
                downType: 1,
                terminalType: '',
                snCode: ''
            },
            form: {
                terminalType: '',
                snCode: '',
                upType: 1,
                serviceDate: []
            },
            downRules: {
                snCode: [
                    { required: true, message: '不能为空', trigger: 'change' }
                ],
                terminalType: [
                    { required: true, message: '不能为空', trigger: 'change' }
                ]
            },
            rules: {
                snCode: [
                    { required: true, message: '不能为空', trigger: 'change' }
                ],
                serviceDate: [
                    { required: true, message: '不能为空', trigger: 'change' }
                ],
                terminalType: [
                    { required: true, message: '不能为空', trigger: 'change' }
                ]
            },
            totalNum: 0,
            position: 1, // 页码
            Ip: '',
            showApk: false,
            currRow: {},
            isLoading: false,
            isdbUploading: false,
            isUploading: false,
            searchNo: '',
            searchName: '',
            checkRow: {},
            dialogVisibleCheck: false,
            check1: false,
            check2: false,
            specPointStart: 20, // 最小授权点数
            authMaxPoint: 25, // 最大授权点数

            editThemeCompanyId: '', // 当前编辑皮肤包的公司id
            editThemeType: 1, // 当前编辑皮肤包的公司类型
            editThemeList: [], // 皮肤包列表
            showTheme: false, // 是否显示皮肤包列表
            serviceSelect: '',
            checkB: false,
            checkC: false,
            serviceDate: '',
            addservicecompanylist: [],
            editServiceCompanyId: '',
            timeStart: '',
            timeEnd: '',
            companyCodeInfo: '',
            companyNameInfo: '',
            currentRate: 0, // 费率
            showRate: false, // 费率修改弹窗
            options4: []
        }
    },
    mounted () {
    },
    created () {
        if (this.$store.state.agentId !== '') {
            this.value1 = this.$store.state.agentId
        }
        this.getCanUploadTerminalType()
        this.getAllAgent()
        this.getPage()
        this.getOssUploadDBUrl()
        this.getThemeList()
        // setInterval(this.refreshPage, 20000)
    },
    watch: {
        position () {
            this.getPage()
        },
        value1 () {
            this.$store.dispatch('agentId', this.value1)
        }
    },
    components: {
        projectorDialog,
        appointAPK,
        authorizationDialog,
        synchronousShop,
        batchMerchant,
        addPlace
    },
    props: {
        underLine: null,
        managementType: Number,
        status: Number
    },
    computed: {
        isUpData () {
            return this.$store.state.isUpData
        },
        roleId () {
            return this.$store.state.roleId
        },
        manageRoleType () {
            return this.$store.state.manageRoleType
        },
        // status () {
        //     return this.$store.state.status
        // },
        // editThemeType
        editThemeListAfter () {
            let after = []
            this.editThemeList.forEach(item => {
                if (item.type === this.editThemeType) {
                    after.push(item)
                }
            })
            return after
        }
    },
    methods: {
        toBatch (item) {
            this.isShowBatch = true
            this.currRow = item
        },
        toBatchAll () {
            this.isShowBatchAll = true
        },
        // 退货按钮
        returnGood (item) {
            this.$confirm('确认退货吗?', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                const res = this.$http.post(this.$store.state.IP + '/system/company/deactivate', {
                    data: { companyId: item.companyId }
                }).then(response => {
                    response = response.body
                    if (response.ret === '0') {
                        this.$message({
                            type: 'success',
                            message: '退货成功!'
                        })
                        // 刷新数据
                        this.getPage()
                    } else {
                        this.$message({
                            type: 'info',
                            message: '退货失败!'
                        })
                    }
                }, response => {
                })
                // window.location.reload()
                // this.$router.go(0)
                // console.log('开始打印item.companyId了')
                // console.log(item.companyId)
                console.log('开始打印res了')
                console.log(res)
                console.log('状态是')
                // console.log(status)
                console.log(this)
                console.log('状态是')
                console.log(item.status)
                // console.log(response.status)
                // console.log('开始打印res.data了')
                // console.log(res.data)
                console.log('打印结束了')
                // this.$router.go()
            }).catch(() => {
                this.$message({
                    type: 'info',
                    message: '已取消退货'
                })
            })
        },
        // 清空数据
        clearData2 () {
            this.dialogVisible2 = false
            this.snList = []
            this.$refs['downForm'].resetFields()
        },
        clearData () {
            this.dialogVisible1 = false
            this.buttonDisabled = false
            this.snList = []
            this.$refs['form'].resetFields()
        },
        async getSNList (terminalType) {
            this.form.snCode = ''
            this.downForm.snCode = ''
            const res = await this.$http.post(this.$store.state.IP + '/center/get/activeSns', {
                companyCode: this.currRow.companyCode,
                terminalType: terminalType
            })
            let response = res.data
            if (response.ret === '0') {
                this.snList = response.data || []
            }
        },
        getCanUploadTerminalType () {
            this.$http.get(this.$store.state.IP + '/system/company/getCanUploadTerminalType', {
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.terminalTypeList = response.data
                }
            }, response => {
            })
        },
        projectorEdition (i, row) {
            this.currRow = row
            this.isShowProjector = true
        },
        resetPassword (row) {
            this.$confirm('确定重置密码为 syclub ?', '重置密码', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$http.post(this.$store.state.IP + '/system/company/resetCompanyPsw', {
                    data: {
                        companyCode: row.companyCode,
                        managementType: this.managementType
                    }
                },
                    {
                        'emulateJSON': false
                    }
                ).then(response => {
                    response = response.body
                    console.log(response)
                    if (response.ret === '0') {
                        this.$message({
                            showClose: true,
                            message: '重置成功',
                            type: 'success'
                        })
                    }
                }, response => {
                })
            }).catch(() => {
            })
        },
        toModify (index, row) {
            this.$store.dispatch('setKM', 3)
            this.$store.dispatch('setKAE', row.companyId)
        },
        toServiceList (index, row) {
            this.$store.dispatch('setKM', 4)
            this.$store.dispatch('setKMS', row.companyCode)
        },

        openRateEdit (index, row) {
            // 修改费率 弹窗
            this.currentRate = row.netPayRate
            this.checkRow = row
            this.showRate = true
        },
        toNetPayChannel (index, row) {
            // 网络支付配置
            this.$store.dispatch('setKM', 5)
            this.$store.dispatch('setKAE', row.companyId)
            this.$store.dispatch('setKMCompanyName', row.companyName)
            this.$store.dispatch('setKMManagementType', row.managementType)
        },
        toWareInputReview (index, row) {
            // 进件查看
            if (!this.isUpData) {
                this.$store.dispatch('setKM', 7)
                this.$store.dispatch('setKAE', row.companyCode)
            } else {
                this.$store.dispatch('setKM', 6)
                this.$store.dispatch('setKAS', row.companyCode)
            }
        },
        saveRate () {
            let reg = ''
            // 如果有小数
            if (String(this.currentRate).indexOf('.') > -1) {
                reg = /^[0-9]+(.[0-9])?$/g
            } else {
                reg = /^\+?[1-9][0-9]*$/g
            }
            if (!reg.test(this.currentRate)) {
                this.$message({
                    showClose: true,
                    message: '请设置正确的费率',
                    type: 'warning'
                })
                return false
            }
            if (this.currentRate < 2.8) {
                this.$message({
                    showClose: true,
                    message: '费率不得小于 2.8',
                    type: 'warning'
                })
                return false
            }
            // 发送请求
            this.$http.post(this.$store.state.IP + '/system/company/editCompanyNetPayRate', {
                data: {
                    companyID: this.checkRow.companyId,
                    netPayRate: this.currentRate
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.$message({
                        showClose: true,
                        message: '费率修改成功',
                        type: 'success'
                    })
                    // 修改成功
                    this.showRate = false
                    // 刷新数据
                    this.getPage()
                } else {
                    this.$message({
                        showClose: true,
                        message: response.msg || '费率修改失败',
                        type: 'warning'
                    })
                }
            })
        },
        openCheck (row) {
            this.dialogVisibleCheck = true
            this.checkRow = row
            if (row.wideNetEnable === 1) {
                this.check1 = true
            } else {
                this.check1 = false
            }
            if (row.supportExtandPoint) {
                this.check2 = true
            } else {
                this.check2 = false
            }
            this.specPointStart = row.specPointStart
            this.authMaxPoint = row.authMaxPoint
        },
        saveCheck () {
            this.$http.post(this.$store.state.IP + '/system/company/optPermissions', {
                data: {
                    wideNetEnable: this.check1 ? 1 : 0,
                    supportExtandPoint: this.check2 ? 1 : 0,
                    companyID: this.checkRow.companyId
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('设置特殊权限成功')
                    this.$message({
                        showClose: true,
                        message: '设置特殊权限成功',
                        type: 'success'
                    })
                    this.dialogVisibleCheck = false
                    this.getPage()
                }
                if (response.ret !== '0') {
                    console.log('设置特殊权限成功')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        controlClass (manageClass) {
            console.log(manageClass)
            if (manageClass.router === 'change') {
                this.toHistory(manageClass.index, manageClass.row)
            }
            if (manageClass.router === 'update') {
                this.toUpdateHistory(manageClass.index, manageClass.row)
            }
        },
        refreshPage () {
            if (this.$store.state.page1KTVManage === 0 && this.$store.state.roleId === 1 && this.$store.state.hasLogin && this.$store.state.showRefreshPage) {
                this.$store.dispatch('agentId', '')
                this.value1 = ''
                this.getPage()
            }
        },

        refreshLog (index, row) {
            this.dialogVisible1 = true
            this.companyID = row.companyId
        },
        temporaryAuthorization (row) {
            this.showTemporaryAuthorization = true
            this.currRow = row
        },
        // 数据拉取
        refreData (index, row) {
            this.dialogVisible1 = true
            this.currRow = row
            this.companyID = row.companyId
            this.dbUploading = row.dbUploading
            this.isSuccess = row.isSuccess
            this.checkList = []
        },
        // 数据下载
        downData (index, row) {
            this.currRow = row
            this.dialogVisible2 = true
            this.hasLog = row.hasLog
            this.companyID = row.companyId
            this.isSuccess = row.isSuccess
            this.checkListDownload = []
        },
        realRefresh () {
            this.$refs.form.validate((valid) => {
                if (valid) {
                    this.upLoading = true
                    this.buttonDisabled = true
                    this.isUploading = true
                    this.$http.post(this.$store.state.IP + '/center/uploadCompanyLog', {
                        companyCode: this.currRow.companyCode,
                        ...this.form,
                        startDate: this.form.serviceDate[0],
                        endDate: this.form.serviceDate[1],
                        type: 1
                    },
                        {
                            'emulateJSON': false
                        }
                    ).then(response => {
                        response = response.body
                        this.isUploading = false
                        this.upLoading = false
                        if (response.ret === '0') {
                            this.clearData()
                            this.getPage()
                        }
                        if (response.ret !== '0') {
                            console.log('调用更新日志接口失败')
                        }
                        console.log('******************************************')
                    }, response => {
                        console.log('通讯失败')
                    })
                }
            })
        },
        // 强制提取数据
        handleCommand () {
            this.realRefreshTwo(false)
        },
        dbUploadingEvent () {
            this.dbUploading = true
        },
        realRefreshTwo (val) {
            this.dbUploading = val
            this.isdbUploading = true
            this.upLoading = true
            this.$http.post(this.$store.state.IP + '/center/uploadCompanyDBData', {
                companyCode: this.currRow.companyCode
            }).then(response => {
                response = response.body
                this.isdbUploading = false
                this.dialogVisible1 = false
                this.upLoading = false
                if (response.ret === '0') {
                    console.log('数据库拉取成功')
                    this.getPage()
                    this.clearData()
                }
                if (response.ret !== '0') {
                    console.log('数据库拉取失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        getOssUploadDBUrl () {
            // let self = this
            let params = {
                params: {
                }
            }
            this.$http.get(this.$store.state.IP + '/ossUploadDBUrl', params
            ).then(response => {
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('数据库拉取成功')
                    this.ossUploadDBUrl = response.data
                }
                if (response.ret !== '0') {
                    console.log('数据库拉取失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        async downloadLog (downloadType) {
            this.$refs.downForm.validate(async (valid) => {
                if (valid) {
                    this.isLoading = true
                    const res = await this.$http.post(this.$store.state.IP + '/center/downloadCompanyLogOrDBData', {
                        companyCode: this.currRow.companyCode,
                        downloadType: downloadType,
                        ...this.downForm
                    })
                    let response = res.data
                    if (response.ret === '0') {
                        this.isLoading = false
                        let name = this.checkBrowser()
                        if (name === '360') {
                            window.open(response.data)
                        } else {
                            window.location = response.data
                        }
                        this.clearData2()
                    } else {
                        this.isLoading = false
                    }
                }
            })
        },
        getVersionList (index, row) {
            this.showChangeVersion = true
            this.currRow = row
        },

        changeVersion (index, row) {
            this.$http.post(this.$store.state.IP + '/system/company/setSpecifiedVersion', {
                data: {
                    companyid: this.editVersionCompanyId,
                    specifiedVersionCode: row.versionCode
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('指定apk版本信息成功')
                    console.log(response.data)
                    this.showChangeVersion = false
                    this.getPage()
                }
                if (response.ret !== '0') {
                    console.log('指定apk版本信息失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        toEdition (index, row) {
            this.$store.dispatch('setKM', 8)
            this.$store.dispatch('setCurrRow', row)
        },
        getThemeList () {
            let params = {
                params: {
                    managementType: this.managementType,
                    terminalType: 1
                }
            }
            this.$http.get(this.$store.state.IP + '/skinPackage/findAll', params).then(response => {
                console.log('-------------------------------------------')
                console.log('调用登出返回')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.editThemeList = response.res
                    console.log('调用登出成功')
                }
                if (response.ret !== '0') {
                    console.log('调用登出失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },
        toSetTheme (index, row) {
            this.editThemeCompanyId = row.companyId
            this.editThemeType = row.managementType
            this.showTheme = true
        },
        changeTheme (index, row) {
            let params = {
                params: {
                    companyID: this.editThemeCompanyId,
                    id: row.id
                }
            }
            this.$http.get(this.$store.state.IP + '/skinPackage/pull', params).then(response => {
                console.log('-------------------------------------------')
                console.log('调用登出返回')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.showTheme = false
                    this.getPage()
                    console.log('调用登出成功')
                }
                if (response.ret !== '0') {
                    console.log('调用登出失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },

        search () {
            if (this.endTime) {
                if (this.endTime < this.beginTime) {
                    return this.$message({
                        message: '开始时间不能大于结束时间',
                        type: 'warning'
                    })
                }
            }
            this.position = 1
            this.getPage()
        },
        toHistory (index, row) {
            this.$store.dispatch('setKM', 1)
            this.$store.dispatch('setKMH', row.companyCode)
        },
        toUpdateHistory (index, row) {
            this.$store.dispatch('setKM', 2)
            this.$store.dispatch('setKMU', row.companyId)
        },
        getAllAgent () {
            this.$http.get(this.$store.state.IP + '/systemUserManage/getAgents', {
                data: {
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('调用获取所有代理商成功')
                    this.options1 = response.res
                }
                if (response.ret !== '0') {
                    console.log('调用获取所有代理商失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },

        exportRport () {
            if (this.endTime) {
                if (this.endTime < this.beginTime) {
                    return this.$message({
                        message: '开始时间不能大于结束时间',
                        type: 'warning'
                    })
                }
            }
            let that = this
            let endTime = this.endTime ? this.endTime + ' 23:59:59' : ''
            let beginTime = this.beginTime ? this.beginTime + ' 00:00:00' : ''
            axios.get(this.$store.state.IP + '/system/company/exportCompanyExcel' +
                '?companyCode=' + this.searchNo +
                '&companyName=' + this.searchName +
                '&mainCompanyName=' + this.mainCompanyName +
                '&mainCompanyCode=' + this.mainCompanyCode +
                '&agentId=' + this.value1 +
                '&managementType=' + this.managementType +
                '&endTime=' + endTime +
                '&beginTime=' + beginTime,
                {
                    responseType: 'blob',
                    headers: that.axiosDownloadHeaders()
                }
            ).then(function (response) {
                console.log(response)
                if (response.headers['content-type'] === 'application/json;charset=UTF-8') {
                    console.log('出错')
                    return
                }
                let fileName = decodeURIComponent(response.headers['content-disposition'])
                fileName = fileName.substring(20)
                if (response.headers['content-type'] === 'application/x-msdownload;charset=UTF-8') {
                    fileDownload(response.data, fileName)
                }
            }).catch(function (error) {
                alert(error)
            })
        },

        getPage () {
            this.$http.post(this.$store.state.IP + '/system/company/page', {
                data: {
                    page: this.position - 1, // 页数
                    limit: 10, // 一页显示数量
                    companyCode: this.searchNo,
                    companyName: this.searchName,
                    mainCompanyCode: this.mainCompanyCode,
                    mainCompanyName: this.mainCompanyName,
                    beginTime: this.beginTime ? this.beginTime + ' 00:00:00' : '',
                    endTime: this.endTime ? this.endTime + ' 23:59:59' : '',
                    agentId: this.value1,
                    managementType: this.managementType
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('调用商家列表成功')
                    console.log(response.data)
                    this.showList = response.data.list
                    this.totalNum = response.data.total
                }
                if (response.ret !== '0') {
                    console.log('调用商家列表失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
            })
        },

        // 换页方法
        handleCurrentChange (val) {
            this.position = val
        },
        // 数据重新上传K米
        refreshKmData (index, row) {
            console.log(row)
            let companyIDs = []
            companyIDs.push(row.companyId)
            this.$http.post(this.$store.state.IP + '/kmshop/refresh', {
                companyIDs: companyIDs
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    this.$message({
                        showClose: true,
                        message: '数据重新上传K米成功',
                        type: 'success'
                    })
                }
                if (response.ret !== '0') {
                    console.log('调用数据重新上传K米失败')
                }
                console.log('******************************************')
            }, response => {
                console.log('调用数据重新上传K米失败')
            })
        },
        changeService (index, row) {
            this.checkB = false
            this.checkC = false
            this.serviceSelect = ''
            this.timeStart = ''
            this.timeEnd = ''
            this.showBapingServe = row.managementType === 2
            this.hasBaping = false
            this.companyCodeInfo = row.companyCode
            this.companyNameInfo = row.companyName
            this.editServiceCompanyId = row.companyId
            this.addservicecompanylist = row.addServiceCompanyList
            console.log(this.addservicecompanylist)
            for (var i = this.addservicecompanylist.length - 1; i >= 0; i--) {
                console.log(this.addservicecompanylist[i].addServiceCode)
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB001') {
                    this.checkB = true
                }
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB002') {
                    this.checkC = true
                    this.checkB = true
                }
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB003') {
                    this.serviceSelect = 'LYJB003'
                    // this.timeStart = this.$FS(this.addservicecompanylist[i].effectiveTime)
                    this.timeEnd = this.$FS(this.addservicecompanylist[i].expiredTime)
                }
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB004') {
                    this.serviceSelect = 'LYJB004'
                    // this.timeStart = this.$FS(this.addservicecompanylist[i].effectiveTime)
                    this.timeEnd = this.$FS(this.addservicecompanylist[i].expiredTime)
                }
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB005') {
                    this.serviceSelect = 'LYJB005'
                    // this.timeStart = this.$FS(this.addservicecompanylist[i].effectiveTime)
                    this.timeEnd = this.$FS(this.addservicecompanylist[i].expiredTime)
                }
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB006') {
                    this.serviceSelect = 'LYJB006'
                    // this.timeStart = this.$FS(this.addservicecompanylist[i].effectiveTime)
                    this.timeEnd = this.$FS(this.addservicecompanylist[i].expiredTime)
                }
                if (this.addservicecompanylist[i].addServiceCode === 'LYJB007') {
                    this.serviceSelect = 'LYJB007'
                    // this.timeStart = this.$FS(this.addservicecompanylist[i].effectiveTime)
                    this.timeEnd = this.$FS(this.addservicecompanylist[i].expiredTime)
                }
                if (this.addservicecompanylist[i].addServiceCode === 'XXGG001') {
                    this.hasBaping = true
                    this.bapingTimeEnd = this.$FS(this.addservicecompanylist[i].expiredTime)
                }
            }
            this.dialogServiceVisible = true
        },
        cancelDialog () {
            this.dialogServiceVisible = false
        },
        showMessage (message) {
            this.$message({
                showClose: true,
                message: message,
                type: 'warning'
            })
        },
        /* 变更增值服务 */
        okDialog () {
            let message = ''
            let date = new Date()
            let m = date.getMonth() + 1
            let dateEnd = date.getFullYear() + '-' + 0 + m + '-' + date.getDate()
            if (this.serviceSelect !== '') {
                if (this.timeEnd === '' || this.timeEnd === null) {
                    message = '数据可查过期时间不能为空'
                } else if (this.timeEnd <= dateEnd) {
                    message = '数据可查过期时间必须大于当前日期'
                }
            }
            if (this.hasBaping) {
                if (this.bapingTimeEnd === '' || this.bapingTimeEnd === null) {
                    message = '霸屏过期时间不能为空'
                }
            }
            if (message !== '') {
                this.showMessage(message)
                return
            }
            this.$http.post(this.$store.state.IP + '/system/company/editCompanyAddService', {
                data: {
                    companyID: this.editServiceCompanyId,
                    isBuyCardLevelB: this.checkB ? 1 : 0,
                    isBuyCardLevelC: this.checkC ? 1 : 0,
                    isBuyMemoryLength: this.serviceSelect === '' ? 0 : 1,
                    buyMemoryLengthCode: this.serviceSelect,
                    // effectiveTime: this.timeStart + ' 00:00:00',
                    expiredTime: this.timeEnd + ' 00:00:00',
                    isBuyScreen: this.hasBaping ? 1 : 0,
                    screenExpiredTime: this.bapingTimeEnd + ' 00:00:00'
                }
            },
                {
                    'emulateJSON': false
                }
            ).then(response => {
                console.log('-------------------------------------------')
                response = response.body
                console.log(response)
                if (response.ret === '0') {
                    console.log('变更增值服务成功')
                    this.$message({
                        showClose: true,
                        message: '变更增值服务成功',
                        type: 'success'
                    })
                    this.getPage()
                }
                if (response.ret !== '0') {
                    console.log('变更增值服务失败')
                    this.$message({
                        showClose: true,
                        message: response.msg || '变更增值服务失败',
                        type: 'error'
                    })
                }
                console.log('******************************************')
            }, response => {
                console.log('通讯失败')
                this.$message({
                    showClose: true,
                    message: '通讯失败',
                    type: 'error'
                })
            })
            this.dialogServiceVisible = false
        },
        serviceCheckC () {
            if (this.checkC) {
                this.checkB = this.checkC
            }
        },
        serviceCheckB () {
            if (!this.checkB && this.checkC) {
                this.checkC = this.checkB
            }
        },
        serviceBapingCheck (e) {
            // 是否 选择 霸屏
            console.log('e, this.hasBaping')
            console.log(e, this.hasBaping)
        }
    }
}
</script>

<style lang="stylus" rel="stylesheet/stylus">
.items
    width: 180px

.order-report
    width: 100%
    background: #fff
    min-height: calc(100vh - 65px)
    position: relative

    .report-table-top-title
        width: 100%
        height: 64px
        line-height: 64px
        color: #000
        font-size: 18px
        background: #f1f0f5

    .report-table-form1
        width: 100%
        min-height: 40px
        padding: 16px 0 0 22px
        box-sizing: border-box
        background: #fff
        overflow: hidden

        .report-table-form1-line
            min-height: 32px
            margin-bottom: 16px

            .report-table-form1-item
                display: inline-block
                vertical-align: top
                height: 32px
                margin-right: 15px
                line-height: 32px

                &.word
                    margin-right: 0

                &.samll
                    font-size: 15px
                    text-align: left

                &.big
                    margin-right: 100px

    .report-table-block
        width: 100%
        padding-top: 22px
        height: 50px
        background: #fff
        box-sizing: border-box

        .report-table-block-in
            float: right
            padding-right: 17px

    .page-padding-gray-small
        width: 100%
        height: 22px
        background: #f1f0f5

    .page-padding
        width: 100%
        height: 20px
        background: #fff

    .report-table-total
        width: 100%
        font-size: 16px
        color: #409EFF
        padding: 22px
        margin-top: 22px
        box-sizing: border-box
        background: #fff

    .page-all-loading
        position: fixed
        top: 55%
        left: 40%
        width: 200px

.btns
    margin-right: 10px
    margin-bottom: 10px
    margin-left: 0 !important
</style>
